import java.util.Collections;
import java.util.Random;


public class Schlechte_Nacharn 
{
	public static void main(String[] argv)
	{
		Random ran = new Random(0);
		int maxNeighbors = 55;
		
		int[] donation = new int[maxNeighbors];
		int[] maxDonation = new int[maxNeighbors];
		int[] lastMaxNeighbor = new int[maxNeighbors];
		
		for (int i = 0; i < maxNeighbors; i++)
		{
			int temp = ran.nextInt() % 150;
			if (temp < 0) temp *= -1;
			donation[i] = temp;
			lastMaxNeighbor[i] = i;
			maxDonation[i] = 0;
		}
		
		maxDonation[0] = donation[0]; 
		
		for (int i = 0; i < maxNeighbors; i++)
		{
			int nextNeighbor = -1;
			
			// Falls der größte 2te Nachbar hat als lastMaxNeighbor keinen direkten Nachbarn des aktuellen Knotens
			if (maxDonation[(i + maxNeighbors - 2) % (maxNeighbors - 1)] > maxDonation[(i + (maxNeighbors + 2)) % (maxNeighbors - 1)])
			{
				if (lastMaxNeighbor[(i + maxNeighbors - 2) % (maxNeighbors - 1)] != (i + maxNeighbors) % (maxNeighbors - 1))
				{
					nextNeighbor = (i + maxNeighbors - 2) % (maxNeighbors - 1);
					maxDonation[i] += maxDonation[(i + maxNeighbors - 2) % (maxNeighbors - 1)] + donation[i];
				}
				else
				{
					nextNeighbor = (i + (maxNeighbors - 4)) % (maxNeighbors - 1);
					maxDonation[i] += maxDonation[(i + (maxNeighbors - 4)) % (maxNeighbors - 1)] + donation[i];
				}	
			}
			else
			{
				if (lastMaxNeighbor[(i + (maxNeighbors + 2)) % (maxNeighbors - 1)] != (i + maxNeighbors) % (maxNeighbors - 1))
				{
					nextNeighbor = (i + (maxNeighbors + 2)) % (maxNeighbors - 1);
					maxDonation[i] += maxDonation[(i + (maxNeighbors + 2)) % (maxNeighbors - 1)] + donation[i];
				}
				else
				{
					nextNeighbor = (i + (maxNeighbors + 4)) % (maxNeighbors - 1);
					maxDonation[i] = maxDonation[(i + (maxNeighbors + 4)) % (maxNeighbors - 1)] + donation[i];
				}	
			}
			
			for (int j = 0; j < maxNeighbors; j++)
			{
				if (lastMaxNeighbor[j] == lastMaxNeighbor[i])
					lastMaxNeighbor[i] = nextNeighbor;
			}
		}
		int max = 0;
		for (int i = 0; i < maxNeighbors; i++)
		{
			System.out.print(" " + maxDonation[i]);
			if (max < maxDonation[i])
				max = maxDonation[i];
		}
		System.out.println();
		for (int i = 0; i < maxNeighbors; i++)
		{
			System.out.print(" " + lastMaxNeighbor[i]);
		}
		System.out.println();
		System.out.println(max);
		
	}
}
